namespace FileServer.Abstractions.Models.Options;

/// <summary>
/// 上传文件的配置参数
/// </summary>
public class FileServerOptions
{
    /// <summary>
    /// 文件地址
    /// </summary>
    public string FilePath { get; set; }

    /// <summary>
    /// 存储的临时文件位置
    /// </summary>
    public string FileTmpPath { get; set; }


    /// <summary>
    /// 启用文件MD5验证
    /// </summary>
    /// <remarks>防止重复上传</remarks>
    public bool EnableMd5 { get; set; }

    /// <summary>
    /// 大小
    /// </summary>
    public long MaxSize { get; set; }


    /// <summary>
    /// 上传格式
    /// </summary>
    public List<string> ContentType { get; set; }


    public List<FileProviderOptions> FileProviderOptions { get; set; }

    /// <summary>
    /// 扩展的参数服务
    /// </summary>
    public IList<IFileServerOptionsExtension> Extensions { get; }


    public FileServerOptions()
    {
        Extensions = new List<IFileServerOptionsExtension>();
        FileProviderOptions = new List<FileProviderOptions>();
    }

    /// <summary>
    /// Registers an extension that will be executed when building services.
    /// </summary>
    /// <param name="extension"></param>
    public void RegisterExtension(IFileServerOptionsExtension extension)
    {
        if (extension == null) throw new ArgumentNullException(nameof(extension));

        Extensions.Add(extension);
    }

}